package pl.omega.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class FilmViewPage extends InternalPage {

	public FilmViewPage(PageManager pages) {
		super(pages);
	}

	public InternalPage ensurePageLoaded() {
	    super.ensurePageLoaded();
	    wait.until(presenceOfElementLocated(By.cssSelector("img[alt=\"Seen\"]")));
	    return this;
	}
	
	@FindBy(css = "img[alt=\"Remove\"]")
	private WebElement deleteButton;
	
	public FilmListPage clickDeleteButton() {
		deleteButton.click();
		wait.until(alertIsPresent()).accept();
	    return pages.filmListPage;
	}
}